﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
					xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
					xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
					xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
					xmlns:Shell="clr-namespace:Microsoft.Windows.Shell;assembly=Microsoft.Windows.Shell"
					xmlns:Root="clr-namespace:Elysium.Theme"
					xmlns:Controls="clr-namespace:Elysium.Theme.Controls">

	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="/Elysium.Theme;component/Themes/SharedResources.xaml"/>
		<ResourceDictionary Source="/Elysium.Theme;component/Themes/buttons/CommandButtonsBase.xaml"/>
	</ResourceDictionary.MergedDictionaries>

	<Style x:Key="{x:Type Controls:Window}" TargetType="{x:Type Controls:Window}">

		<Setter Property="Background" Value="{StaticResource Background}"/>
		<Setter Property="BorderBrush" Value="{StaticResource ForegroundMiddlelight}"/>
		<Setter Property="BorderThickness" Value="0"/>
		<Setter Property="Foreground" Value="{StaticResource Foreground}"/>
		<Setter Property="FontFamily" Value="{x:Static Root:Parameters.FontFamily}"/>
		<Setter Property="FontSize" Value="{x:Static Root:Parameters.TextFontSize}"/>
		<Setter Property="FontWeight" Value="Normal"/>
		<Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
		<Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
		<Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
		
		<Setter Property="ResizeMode" Value="CanResizeWithGrip"/>

		<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
		<Setter Property="VerticalContentAlignment" Value="Stretch"/>
		<Setter Property="Padding" Value="0"/>

		<Setter Property="UseLayoutRounding" Value="True"/>
		<Setter Property="SnapsToDevicePixels" Value="True"/>
		
		<Setter Property="Shell:WindowChrome.WindowChrome">
			<Setter.Value>
				<Shell:WindowChrome CaptionHeight="{Binding RelativeSource={RelativeSource AncestorType={x:Type Controls:Window}}, Path=NonclientHeight}"
									CornerRadius="0"
									GlassFrameThickness="0,1,0,0"
									ResizeBorderThickness="1"/>
			</Setter.Value>
		</Setter>
		
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Controls:Window}">
					
					<Border Background="{TemplateBinding Background}"
							BorderBrush="{TemplateBinding BorderBrush}"
							BorderThickness="{TemplateBinding BorderThickness}"
							SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
						<Grid x:Name="LayoutRoot">
							<Grid.RowDefinitions>
								<RowDefinition Height="Auto"/>
								<RowDefinition Height="*"/>
							</Grid.RowDefinitions>
							<Rectangle Grid.Row="0"
									   Fill="#FF5800"
									   StrokeThickness="0"
									   VerticalAlignment="Top"
									   Width="{TemplateBinding Width}"
									   Height="2"/>
							<Grid x:Name="PART_Caption"
							  Grid.Row="0">
								<Grid.ColumnDefinitions>
									<ColumnDefinition Width="Auto"/>
									<ColumnDefinition Width="*"/>
									<ColumnDefinition Width="Auto"/>
								</Grid.ColumnDefinitions>
								<StackPanel Grid.Column="2"
											Orientation="Horizontal"
											Shell:WindowChrome.IsHitTestVisibleInChrome="True" Margin="0,4,4,0">
									<TextBlock Text="WP7 EMULATOR SKIN SWITCHER" TextWrapping="Wrap" Width="120" TextAlignment="Right" Foreground="Black" FontFamily="Segoe WP Bold" FontSize="14" LineHeight="15" LineStackingStrategy="BlockLineHeight"></TextBlock>
									<Rectangle Width="10" Height="40" Fill="#FF5800" Margin="5 -10 0 0"></Rectangle>
									<Controls:CommandButton x:Name="PART_Minimize"
																	BorderThickness="0"
																	Width="15" Height="15" VerticalAlignment="Top">
										<Image Source="pack://application:,,,/Elysium.Theme;component/Icons/Minimize.png"
											   Stretch="None"
											   RenderOptions.BitmapScalingMode="NearestNeighbor"
											   Width="10" Height="10" VerticalAlignment="Top"/>
										<i:Interaction.Triggers>
											<i:EventTrigger EventName="Click">
												<ei:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
																		 PropertyName="WindowState"
																		 Value="{x:Static WindowState.Minimized}"/>
											</i:EventTrigger>
										</i:Interaction.Triggers>
									</Controls:CommandButton>
									<Controls:ToggleCommandButton x:Name="PART_MaximizeRestore"
																		  BorderThickness="0"
																		  Width="15" Height="15" VerticalAlignment="Top">
										<Controls:ToggleCommandButton.Resources>
											<Image x:Key="MaximizeIcon"
												   Source="pack://application:,,,/Elysium.Theme;component/Icons/Maximize.png"
												   Stretch="None"
												   RenderOptions.BitmapScalingMode="NearestNeighbor"
												   Width="10" Height="10"/>
											<Image x:Key="RestoreIcon"
												   Source="pack://application:,,,/Elysium.Theme;component/Icons/Restore.png"
												   Stretch="None"
												   RenderOptions.BitmapScalingMode="NearestNeighbor"
												   Width="10" Height="10"/>
										</Controls:ToggleCommandButton.Resources>
										<Controls:ToggleCommandButton.Style>
											<Style TargetType="{x:Type Controls:ToggleCommandButton}" BasedOn="{StaticResource CommandButtonsBaseStyle}">
												<Setter Property="Content" Value="{StaticResource MaximizeIcon}"/>
												<Style.Triggers>
													<Trigger Property="IsChecked" Value="True">
														<Setter Property="Content" Value="{StaticResource RestoreIcon}"/>
													</Trigger>
												</Style.Triggers>
											</Style>
										</Controls:ToggleCommandButton.Style>
										<i:Interaction.Triggers>
											<i:EventTrigger EventName="Click">
												<ei:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
																		 PropertyName="WindowState"
																		 Value="{x:Static WindowState.Normal}"/>
												<ei:ChangePropertyAction TargetObject="{Binding RelativeSource={RelativeSource TemplatedParent}}"
																		 PropertyName="WindowState"
																		 Value="{x:Static WindowState.Maximized}"
																		 IsEnabled="{Binding IsChecked, ElementName=PART_MaximizeRestore}"/>
											</i:EventTrigger>
										</i:Interaction.Triggers>
									</Controls:ToggleCommandButton>
									<Controls:CommandButton x:Name="PART_Close"
																	Command="{x:Static ApplicationCommands.Close}"
																	BorderThickness="0"
																	Width="15" Height="15" VerticalAlignment="Top">
										<Image Source="pack://application:,,,/Elysium.Theme;component/Icons/Close.png"
											   Stretch="None"
											   RenderOptions.BitmapScalingMode="NearestNeighbor"
											   Width="10" Height="10"/>
									</Controls:CommandButton>
								</StackPanel>
							</Grid>
							<AdornerDecorator Grid.Row="1">
								<ContentPresenter/>
							</AdornerDecorator>
							<ResizeGrip x:Name="PART_Grip"
										Grid.Row="1"
										IsTabStop="False"
										Visibility="Collapsed"
										HorizontalAlignment="Right"
										VerticalAlignment="Bottom"/>
						</Grid>
					</Border>
					
					<ControlTemplate.Triggers>
						<Trigger Property="WindowState" Value="Maximized">
							<Setter TargetName="LayoutRoot" Property="Margin" Value="{Binding Source={x:Static Shell:SystemParameters2.Current}, Path=WindowResizeBorderThickness}"/>
						</Trigger>
						<Trigger Property="WindowStyle" Value="{x:Static WindowStyle.None}">
							<Trigger.Setters>
								<Setter TargetName="PART_Minimize" Property="Visibility" Value="Collapsed"/>
								<Setter TargetName="PART_MaximizeRestore" Property="Visibility" Value="Collapsed"/>
								<Setter TargetName="PART_Close" Property="Visibility" Value="Collapsed"/>
							</Trigger.Setters>
						</Trigger>
						<Trigger Property="WindowStyle" Value="{x:Static WindowStyle.ToolWindow}">
							<Trigger.Setters>
								<Setter TargetName="PART_Minimize" Property="Visibility" Value="Collapsed"/>
								<Setter TargetName="PART_MaximizeRestore" Property="Visibility" Value="Collapsed"/>
							</Trigger.Setters>
						</Trigger>
						<Trigger Property="ResizeMode" Value="CanResizeWithGrip">
							<Trigger.Setters>
								<Setter TargetName="PART_Grip" Property="Visibility" Value="Visible"/>
							</Trigger.Setters>
						</Trigger>
					</ControlTemplate.Triggers>
					
				</ControlTemplate>
			</Setter.Value>
		</Setter>
        
        <Style.Triggers>
            <Trigger Property="WindowStyle" Value="{x:Static WindowStyle.None}">
                <Setter Property="ResizeMode" Value="NoResize"/>
            </Trigger>
            <Trigger Property="WindowStyle" Value="{x:Static WindowStyle.ToolWindow}">
                <Setter Property="ResizeMode" Value="NoResize"/>
            </Trigger>            
        </Style.Triggers>
		
	</Style>
	
</ResourceDictionary>